import warnings
# 忽略所有警告
warnings.simplefilter('ignore')

access_sql_dq="SELECT COUNT(*) as DQ FROM Results where Comment LIKE '%DQ%'"#对切数量sql语句
access_sql_danshua="SELECT eta,isc,uoc,ff FROM Results ORDER BY UniqueId ASC"#单刷趋势图sql语句
tpe_sql_dweta=f"""
        SELECT 
            Classification as BinFileName,
            Class, 
            AOI_1_R as Aoi1R,
            COUNT(bin) AS sum_IvGrade,
            avg(eta) AS eta1
        FROM 
            Results
        GROUP BY 
            Classification,
            Class, 
            AOI_1_R
        """#半片档位占比sqleta语句
tpe_sql_sumbin="SELECT Classification as BinFileName,bin as binn,count(bin) as quantity FROM Results GROUP BY Classification,bin"#查找总bin数量sql语句
tpe_sql_avgeta="SELECT Classification as BinFileName, count(*) as quantity,avg(eta) as eta1,avg(uoc) as uoc1,avg(isc) as isc1,avg(ff)as ff1,avg(RserLfDfIEC) as rs,avg(RshuntDfDr) as rsh,SUM(IIF(Irev2 < 0, 1, 0)) as irev2_lt_0,SUM(IIF(Irev2 < 0.05, 1, 0)) as irev2_lt_0_05,SUM(IIF(Irev2 < 0.2, 1, 0)) as irev2_lt_0_2,SUM(IIF(Irev2 < 0.3, 1, 0)) as irev2_lt_0_3 FROM Results WHERE ff < 500 GROUP BY Classification"#查找平均效率sql语句
access_sql_dw=f"""
        SELECT 
            Classification,
            Class, 
            IvGrade, 
            Aoi1R,
            COUNT(bin) AS sum_IvGrade
        FROM 
            Results
        GROUP BY 
            BinFileName,
            Class, 
            IvGrade,
            Aoi1R
        """#档位占比sql语句
access_sql_dweta=f"""
        SELECT 
            BinFileName,
            Class, 
            IvGrade, 
            Aoi1R,
            COUNT(bin) AS sum_IvGrade,
            avg(eta) AS eta1
        FROM 
            Results
        GROUP BY 
            BinFileName,
            Class, 
            IvGrade,
            Aoi1R
        """#档位占比sqleta语句
access_sql_sumbin="SELECT BinFileName,bin as binn,count(bin) as quantity FROM Results GROUP BY BinFileName,bin"#查找总bin数量sql语句
access_sql_avgeta="SELECT BinFileName, count(*) as quantity,avg(eta) as eta1,avg(uoc) as uoc1,avg(isc) as isc1,avg(ff)as ff1,avg(Rser) as rs,avg(Rshunt) as rsh,SUM(IIF(Irev2 < 0, 1, 0)) as irev2_lt_0,SUM(IIF(Irev2 < 0.05, 1, 0)) as irev2_lt_0_05,SUM(IIF(Irev2 < 0.2, 1, 0)) as irev2_lt_0_2,SUM(IIF(Irev2 < 0.3, 1, 0)) as irev2_lt_0_3 FROM Results WHERE ff < 500 GROUP BY BinFileName"#查找平均效率sql语句
access_sql_xs_opening="SELECT TOP 1 CalibrationValue as xs_isc,CellTempOffset as xs_uoc,Busbar as xs_ff FROM Results ORDER BY UniqueId ASC"#开班修正系数sql语句
access_sql_xs_current="SELECT TOP 1 CalibrationValue as xs_isc,CellTempOffset as xs_uoc,Busbar as xs_ff FROM Results ORDER BY UniqueId DESC"#当前修正系数sql语句
getdb_all_sql="SELECT * FROM ip_config"#获取网站数据库所有配置sql语句
db_path = r"D:\Users\c19471\Desktop\tianeye\database\test.db"#网站数据库路径